import request from '@/router/axios';

export const saveOrUpdate = (data) => {
	return request({
		url: '/activity/sellerActivity/saveOrUpdate',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: data
	})
}
export const getActList = (page, size, params) => {
	return request({
		url: '/activity/sellerActivity/list',
		method: 'post',
		params: {
			...params,
			page,
			size,
		}
	})
}
export const joinActivity = (data) => {
	return request({
		url: '/activity/sellerActivity/joinActivity',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data:data
	})
}
export const listActivity = (page, size, params) => {
	return request({
		url: '/activity/sellerActivityGoods/list',
		method: 'post',
		params: {
			...params,
			page,
			size,
			goodsStatus:0
		}
	})
}

//验证活动输入的折扣
export function testAcRebate(rule, value, callback) {
	if(!value){
		return callback(new Error('输入不可以为空'));
	}else if(value=='0'){
		return callback(new Error('不可输入0'));
	} else if(!Number(value)){
		return callback(new Error('输入值需要为数字值'));
	}else if(value<0 ||  value>=10){
		return callback(new Error('值要大于0小于10'));
	}else{
		callback();
	}
}
export const getActPlatformList = (page, size, params) => {
	return request({
		url: '/activity/sellerActivity/platformList',
		method: 'post',
		params: {
			...params,
			page,
			size,
		}
	})
}
// 参加活动的商品
export const getGoodsList = (page, size, params) => {
  return request({
    url: "/base/sellerGoods/joinActivityList",
    method: "post",
    params: {
      ...params,
      page,
      size
    }
  });
};
// 删除被拒绝的活动商品
export const delByRefused = (data) => {
	return request({
		url: "/activity/sellerActivityGoods/delByRefused",
		method: "post",
		meta: {
			isSerialize: true,
		},
		data: data
	});
};
// 查询当前店铺信息
export const getStoreInfo = (data) => {
	return request({
		url: '/base/sellerStore/getStoreInfo',
		method: 'post',
		data:data,
	})
}

//获取商品分类树
export const getClassTree = () => {
	return request({
		url: "/base/sellerGoodsClass/classData",
		method: "post",
	});
};